﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:conv="clr-namespace:OneStopProgrammingMatrix.Converters">

    <Style x:Key="SeparatorStyle" TargetType="Border">
        <Setter Property="BorderBrush" Value="DarkGray" />
        <Setter Property="BorderThickness" Value="1" />
        <Setter Property="CornerRadius" Value="2" />
        <Setter Property="Margin" Value="5,2" />
        <Setter Property="VerticalAlignment" Value="Stretch" />
    </Style>

    <Style x:Key="TitleBackgroundStyle" TargetType="Border">
        <Setter Property="Margin" Value="0,0,0,2.5" />
        <Setter Property="CornerRadius" Value="5" />
        <Setter Property="Background" Value="Blue" />
    </Style>

    <Style x:Key="TitleTextStyle" TargetType="TextBlock">
        <Setter Property="FontWeight" Value="Bold" />
        <Setter Property="Foreground" Value="White" />
        <Setter Property="Margin" Value="10,2" />
        <Setter Property ="VerticalAlignment" Value="Center" />
    </Style>

    <Style x:Key="ToggleDisplayViewStyle" TargetType="ToggleButton">
        <Style.Triggers>
            <Trigger Property="IsChecked" Value="True">
                <Setter Property="Content">
                    <Setter.Value>
                        <Grid>
                            <UniformGrid Rows="3" Columns="3">
                                <UniformGrid.Resources>
                                    <Style x:Key="SquareStyle" TargetType="Rectangle">
                                        <Setter Property="Height" Value="5" />
                                        <Setter Property="Width" Value="5" />
                                        <Setter Property="Fill" Value="Black" />
                                        <Setter Property="Margin" Value="1" />
                                    </Style>
                                </UniformGrid.Resources>
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                                <Rectangle Style="{StaticResource SquareStyle}" />
                            </UniformGrid>
                        </Grid>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="IsChecked" Value="False">
                <Setter Property="Content">
                    <Setter.Value>
                        <Grid>
                            <UniformGrid Rows="3" Columns="3">
                                <UniformGrid.Resources>
                                    <Style x:Key="RectangleStyle" TargetType="Rectangle">
                                        <Setter Property="Height" Value="5" />
                                        <Setter Property="Width" Value="5" />
                                        <Setter Property="Fill" Value="Black" />
                                        <Setter Property="Margin" Value="1" />
                                    </Style>
                                    <Style x:Key="RectLStyle" TargetType="Rectangle" BasedOn="{StaticResource RectangleStyle}">
                                        <Setter Property="Margin" Value="1" />
                                    </Style>
                                    <Style x:Key="RectMStyle" TargetType="Rectangle" BasedOn="{StaticResource RectangleStyle}">
                                        <Setter Property="Margin" Value="1,1,-0.5,1" />
                                    </Style>
                                    <Style x:Key="RectRStyle" TargetType="Rectangle" BasedOn="{StaticResource RectangleStyle}">
                                        <Setter Property="Margin" Value="-0.5,1,1,1" />
                                    </Style>
                                </UniformGrid.Resources>
                                <Rectangle Style="{StaticResource RectLStyle}" />
                                <Rectangle Style="{StaticResource RectMStyle}" />
                                <Rectangle Style="{StaticResource RectRStyle}" />
                                <Rectangle Style="{StaticResource RectLStyle}" />
                                <Rectangle Style="{StaticResource RectMStyle}" />
                                <Rectangle Style="{StaticResource RectRStyle}" />
                                <Rectangle Style="{StaticResource RectLStyle}" />
                                <Rectangle Style="{StaticResource RectMStyle}" />
                                <Rectangle Style="{StaticResource RectRStyle}" />
                            </UniformGrid>
                        </Grid>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="MatrixItemStyle" TargetType="ListBox">
        <Style.Resources>
            <conv:UIOffsetConverter x:Key="UIOffsetConverter" />
            <conv:MatrixItemMnemonicConverter x:Key="MatrixItemMnemonicConverter" />
        </Style.Resources>

        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <ItemsPresenter Margin="10,5" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <WrapPanel Name="itmPanel" IsItemsHost="True" Width="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ScrollContentPresenter}}, Converter={StaticResource UIOffsetConverter}, ConverterParameter=V}" />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate">
            <Setter.Value>
                <DataTemplate>
                    <Button Name="btnOpenPath" Margin="5,2" Width="150" FontWeight="Bold"
                            HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                            HorizontalContentAlignment="Center" VerticalContentAlignment="Center"
                            Command="{Binding DataContext.OpenLinkCommand, RelativeSource={RelativeSource AncestorType=ListBox}}"
                            CommandParameter="{Binding Path}">
                        <Button.ToolTip>
                            <Border CornerRadius="5">
                                <!--<TextBlock>
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="{}Click to open &quot;{0}&quot;&#x0a;Desc (remove header): &lt;Italic&gt;{1}&lt;/Italic&gt;&#x0a;( {2} )">
                                            <Binding Path="Name" />
                                            <Binding Path="Description" />
                                            <Binding Path="Path" />
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>-->
                                <TextBlock>
                                    <Run Text="{Binding Name, StringFormat='Click to open &quot;{0}&quot;&#x0a;'}" />
                                    <!--<Run Text="&#x0a;" />-->
                                    <Run Text="{Binding Description, StringFormat='{}{0}&#x0a;'}" FontStyle="Italic" />
                                    <!--<Run Text="&#x0a;" />-->
                                    <Run Text="( " />
                                    <Hyperlink NavigateUri="{Binding BUri}">
                                        <Run Text="{Binding Path, StringFormat='{}{0}'}"/>
                                    </Hyperlink>
                                    <Run Text=" )" />
                                </TextBlock>
                            </Border>
                        </Button.ToolTip>
                        <!--<Button.Template>
                            <ControlTemplate TargetType="{x:Type Button}">
                                <Border CornerRadius="5" BorderBrush="Gray" BorderThickness="1">
                                    <ContentPresenter Margin="15,5" HorizontalAlignment="Center" VerticalAlignment="Center" />
                                </Border>
                            </ControlTemplate>
                        </Button.Template>-->
                        <Button.Content>
                            <MultiBinding Converter="{StaticResource MatrixItemMnemonicConverter}">
                                <Binding Path="Name" />
                                <Binding Path="MatrixGroup" />
                            </MultiBinding>
                        </Button.Content>
                        <Button.ContextMenu>
                            <ContextMenu>
                                <MenuItem Name="mnuEdit" Header="Edit" />
                                <MenuItem Name="mnuDelete" Header="Delete" />
                            </ContextMenu>
                        </Button.ContextMenu>
                    </Button>
                </DataTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
